package com.starbaba.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;

import com.jumai.server.qiniu.QiniuUploadUtils;
import com.starbaba.model.dictionary.Constant;
import com.starbaba.model.utils.UpdateIndex;
import com.starbaba.tools.config.ConfigFile;
import com.starbaba.tools.config.ConfigFileFactory;
import com.tuanzi.server.loan_base.constant.LoanConstant;

public class ContextListener implements ServletContextListener {
	static Logger logger = Logger.getLogger(ContextListener.class);

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
	}

	@Override
	public void contextInitialized(ServletContextEvent se) {
		ConfigFile configFile = ConfigFileFactory.getInstance()
				.get("ipaddress");
		LoanConstant.initLoanSpaceName();
		QiniuUploadUtils.init();
		String ipaddress = configFile.getValue("common");
		//com.starbaba.life.util.UpdateRedis.REDIS_URL = ipaddress;
		UpdateIndex.INDEX_URL = ipaddress;
		com.starbaba.model.utils.UpdateIndex.INDEX_URL = ipaddress;
		Constant.COMMON_HOST = ipaddress;
		logger.info("xmiles services address : " + ipaddress);
		logger.info("webapp server is started!");
	}
}
